package com.orion.enumeration;

import com.orion.domain.Result;

/**
 * @author Administrator
 * @date 2021/10/9
 */
public enum CommonCodeEnum {
    /**
     * 成功
     */
    COMMON_SUCCESS(1000, "Success"),

    /**
     * 执行失败
     */
    COMMON_FAILURE(1001, "Failure"),

    /**
     * 参数缺失
     */
    COMMON_MISSING_PARAM(1002, "Missing param"),

    /**
     * 无效参数
     */
    COMMON_INVALID_PARAM(1003, "Invalid param"),

    /**
     * 无效请求
     */
    COMMON_INVALID_REQUEST(1004, "Invalid request"),

    /**
     * 未知错误
     */
    COMMON_UNKNOWN_ERROR(1005, "Unknown error"),

    /**
     * 系统错误
     */
    COMMON_SERVER_ERROR(1006, "server_error");


    private Integer code;

    private String msg;

    CommonCodeEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Result toResult(){
        return  new Result( getMsg(),getCode());
    }
}
